package com.marvinlabs.widget.slideshow.demo;

import com.marvinlabs.widget.slideshow.SlideShowView;
import com.marvinlabs.widget.slideshow.adapter.RemoteBitmapAdapter;
import com.marvinlabs.widget.slideshow.adapter.ResourceBitmapAdapter;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.media.image.ImageSource;
import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;

import static org.junit.Assert.assertEquals;

public class ExampleOhosTest {
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("com.marvinlabs.widget.slideshow.demo", actualBundleName);
    }

    @Test
    public void testRemoteBitmapAdapter() {
        Ability ability = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility();
        AbilitySlice slice = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentAbilitySlice(ability);

        RemoteBitmapAdapter adapter = new RemoteBitmapAdapter(slice, new ArrayList<>(), new ImageSource.DecodingOptions());
        Assert.assertNotNull(adapter);
    }

    @Test
    public void testResourceBitmapAdapter() {
        Ability ability = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility();
        AbilitySlice slice = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentAbilitySlice(ability);

        ResourceBitmapAdapter adapter = new ResourceBitmapAdapter(slice, new ArrayList<>(), new ImageSource.DecodingOptions());
        Assert.assertNotNull(adapter);
    }

    @Test
    public void testSlideShowView() {
        Ability ability = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility();
        AbilitySlice slice = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentAbilitySlice(ability);

        SlideShowView slideShowView = new SlideShowView(slice);
        ResourceBitmapAdapter adapter = new ResourceBitmapAdapter(slice, new ArrayList<>(), new ImageSource.DecodingOptions());
        slideShowView.setAdapter(adapter);

        Assert.assertNotNull(slideShowView.getAdapter());
    }
}